﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using POSSystem.BLL;

namespace WebUI
{
    public partial class StockTakeReport : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            if (!IsPostBack)
            {
                POSSystem.BLL.StockTakeReport rptData = new POSSystem.BLL.StockTakeReport();
                rptData.BranchID = Branches.CurrentBranchID;
                rptData.LoadReport("RptStockTake");
                rptViewer.ProcessingMode = ProcessingMode.Local;
                rptViewer.LocalReport.ReportPath = Server.MapPath("~/Report/StockTake.rdlc");
                AddParms();
                ReportDataSource rptDataSource = new ReportDataSource("StockTake", rptData.DefaultView);
                rptViewer.LocalReport.DataSources.Add(rptDataSource);
            }
        }

        private void AddParms()
        {
            ReportParameter parm = new ReportParameter("CompanyName", Branches.CurrentBranch.s_Name);
            rptViewer.LocalReport.SetParameters(parm);
            parm = new ReportParameter("CompanyAddress", Branches.CurrentBranch.s_Address);
            rptViewer.LocalReport.SetParameters(parm);
            parm = new ReportParameter("CompanyABN", Branches.CurrentBranch.s_ABN);
            rptViewer.LocalReport.SetParameters(parm);
            parm = new ReportParameter("CompanyPhone", Branches.CurrentBranch.s_Phone);
            rptViewer.LocalReport.SetParameters(parm);
            parm = new ReportParameter("CompanyFax", Branches.CurrentBranch.s_Fax);
            rptViewer.LocalReport.SetParameters(parm);
            parm = new ReportParameter("reportDate", DateTime.Now.ToString("dd MMM yyyy"));
            rptViewer.LocalReport.SetParameters(parm);
        }
    }
}